/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-06-17
 * Time: 23:03
 */
//day13贪心算法 力扣991 坏了的计算器
public class Main {
        public int brokenCalc(int startValue, int target) {
            //定义一个记录操作数的变量
            int count = 0;
            //情况1：target>startValue
            while (target > startValue) {
                //判断target是否为偶数还是奇数
                if (target % 2 == 0) {
                    target /= 2;
                } else {
                    target++;
                }
                count++;
            }
            //情况2：target <= startValue
            return count + (startValue - target);
        }
}
